package com.zhuojy.equity.mall.admin.common.pojo;

import lombok.Data;

import java.io.Serializable;

/**
 * @author chen
 * @version 1.0
 * @description: TODO
 * @date 2023/10/18 18:51
 */
@Data
public class ResultEntity<T> implements Serializable {

    private static final long serialVersionUID = -7936222308071635283L;

    private Integer code;
    private String message;
    private T data;

    /**
     * @description: 请求成功
     * @author
     * @date 2023-10-18 19:10:08
     * @version 1.0
     */
    public static <T> ResultEntity<T> OK(T data) {
        ResultEntity<T> resultEntity = new ResultEntity<>();
        resultEntity.setCode(ResultStatus.OK.getCode());
        resultEntity.setMessage(ResultStatus.OK.getMessage());
        resultEntity.setData(data);
        return resultEntity;
    }

    /**
     * @description: 请求异常
     * @author
     * @date 2023-10-18 19:10:08
     */
    public static ResultEntity<String> ERROR(String data){
        ResultEntity<String> resultEntity = new ResultEntity<>();
        resultEntity.setCode(ResultStatus.ERROR.getCode());
        resultEntity.setMessage(ResultStatus.ERROR.getMessage());
        resultEntity.setData(data);
        return resultEntity;
    }

    /**
     * @description: 用户未登录
     * @author
     * @date 2023-10-18 19:10:08
     */
    public static ResultEntity<String> USER_NOT_LOGGED(String data){
        ResultEntity<String> resultEntity = new ResultEntity<>();
        resultEntity.setCode(ResultStatus.USER_NOT_LOGGED.getCode());
        resultEntity.setMessage(ResultStatus.USER_NOT_LOGGED.getMessage());
        resultEntity.setData(data);
        return resultEntity;
    }

    /**
     * @description: 用户已登录
     * @author
     * @date 2023-10-18 19:10:08
     */
    public static ResultEntity<String> USER_LOGGED(String data){
        ResultEntity<String> resultEntity = new ResultEntity<>();
        resultEntity.setCode(ResultStatus.USER_LOGGED.getCode());
        resultEntity.setMessage(ResultStatus.USER_LOGGED.getMessage());
        resultEntity.setData(data);
        return resultEntity;
    }

    /**
     * @description: 用户不存在
     * @author
     * @date 2023-10-18 19:10:08
     */
    public static ResultEntity<String> USER_NOT_EXIST(String data){
        ResultEntity<String> resultEntity = new ResultEntity<>();
        resultEntity.setCode(ResultStatus.USER_NOT_EXIST.getCode());
        resultEntity.setMessage(ResultStatus.USER_NOT_EXIST.getMessage());
        resultEntity.setData(data);
        return resultEntity;
    }

    /**
     * @description: 用户已存在
     * @author
     * @date 2023-10-18 19:10:08
     */
    public static ResultEntity<String> USER_EXIST(String data){
        ResultEntity<String> resultEntity = new ResultEntity<>();
        resultEntity.setCode(ResultStatus.USER_EXIST.getCode());
        resultEntity.setMessage(ResultStatus.USER_EXIST.getMessage());
        resultEntity.setData(data);
        return resultEntity;
    }

    /**
     * @description: 账号错误
     * @author
     * @date 2023-10-18 19:10:08
     */
     public static ResultEntity<String> ERROR_NOT_USERNAME(String data){
         ResultEntity<String> resultEntity = new ResultEntity<>();
         resultEntity.setCode(ResultStatus.ERROR_NOT_USERNAME.getCode());
         resultEntity.setMessage(ResultStatus.ERROR_NOT_USERNAME.getMessage());
         resultEntity.setData(data);
         return resultEntity;
     }

     /**
      * @description: 密码错误
      * @author
      * @date 2023-10-18 19:10:08
      */
     public static ResultEntity<String> ERROR_NOT_PASSWORD(String data){
         ResultEntity<String> resultEntity = new ResultEntity<>();
         resultEntity.setCode(ResultStatus.ERROR_NOT_PASSWORD.getCode());
         resultEntity.setMessage(ResultStatus.ERROR_NOT_PASSWORD.getMessage());
         resultEntity.setData(data);
         return resultEntity;
     }
}
